/*
 * Copyright (c) 2025 Huawei Technologies Co., Ltd.
 * openFuyao is licensed under Mulan PSL v2.
 * You can use this software according to the terms and conditions of the Mulan PSL v2.
 * You may obtain a copy of Mulan PSL v2 at:
 *          http://license.coscl.org.cn/MulanPSL2
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 * See the Mulan PSL v2 for more details.
 */

// Package httputil
package httputil

import (
	"net/http"
	"reflect"
	"testing"
)

func TestGetResponseJson(t *testing.T) {
	type args struct {
		code int32
		msg  string
		data any
	}
	tests := []struct {
		name string
		args args
		want *ResponseJson
	}{
		// TODO: Add test cases.
		{
			name: "test1",
			args: args{
				code: 200,
				msg:  "success",
				data: nil,
			},
			want: &ResponseJson{
				Code: 200,
				Msg:  "success",
				Data: nil,
			},
		},
	}
	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			if got := GetResponseJson(tt.args.code, tt.args.msg, tt.args.data); !reflect.DeepEqual(got, tt.want) {
				t.Errorf("GetResponseJson() = %v, want %v", got, tt.want)
			}
		})
	}
}

func TestGetDefaultSuccessResponseJson(t *testing.T) {
	tests := []struct {
		name string
		want *ResponseJson
	}{
		// TODO: Add test cases.
		{
			name: "test1",
			want: &ResponseJson{
				Code: 200,
				Msg:  "success",
				Data: nil,
			},
		},
	}
	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			if got := GetDefaultSuccessResponseJson(); !reflect.DeepEqual(got, tt.want) {
				t.Errorf("GetDefaultSuccessResponseJson() = %v, want %v", got, tt.want)
			}
		})
	}
}

func TestGetDefaultClientFailureResponseJson(t *testing.T) {
	tests := []struct {
		name string
		want *ResponseJson
	}{
		// TODO: Add test cases.
		{
			name: "test1",
			want: &ResponseJson{
				Code: 400,
				Msg:  "bad request",
				Data: nil,
			},
		},
	}
	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			if got := GetDefaultClientFailureResponseJson(); !reflect.DeepEqual(got, tt.want) {
				t.Errorf("GetDefaultClientFailureResponseJson() = %v, want %v", got, tt.want)
			}
		})
	}
}

func TestGetClientFailureResponseJsonWithData(t *testing.T) {
	type args struct {
		data any
	}
	tests := []struct {
		name string
		args args
		want *ResponseJson
	}{
		// TODO: Add test cases.
		{
			name: "test1",
			args: args{
				data: nil,
			},
			want: &ResponseJson{
				Code: 400,
				Msg:  "bad request",
				Data: nil,
			},
		},
	}
	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			if got := GetClientFailureResponseJsonWithData(tt.args.data); !reflect.DeepEqual(got, tt.want) {
				t.Errorf("GetClientFailureResponseJsonWithData() = %v, want %v", got, tt.want)
			}
		})
	}
}

func TestGetDefaultServerFailureResponseJson(t *testing.T) {
	tests := []struct {
		name string
		want *ResponseJson
	}{
		// TODO: Add test cases.
		{
			name: "test1",
			want: &ResponseJson{
				Code: 500,
				Msg:  "remote server busy",
				Data: nil,
			},
		},
	}
	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			if got := GetDefaultServerFailureResponseJson(); !reflect.DeepEqual(got, tt.want) {
				t.Errorf("GetDefaultServerFailureResponseJson() = %v, want %v", got, tt.want)
			}
		})
	}
}

func TestGetServerFailureResponseJsonWithData(t *testing.T) {
	type args struct {
		data any
	}
	tests := []struct {
		name string
		args args
		want *ResponseJson
	}{
		// TODO: Add test cases.
		{
			name: "test1",
			args: args{
				data: nil,
			},
			want: &ResponseJson{
				Code: 500,
				Msg:  "operation failed",
				Data: nil,
			},
		},
	}
	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			if got := GetServerFailureResponseJsonWithData(tt.args.data); !reflect.DeepEqual(got, tt.want) {
				t.Errorf("GetServerFailureResponseJsonWithData() = %v, want %v", got, tt.want)
			}
		})
	}
}

func TestGetParamsEmptyErrorResponseJson(t *testing.T) {
	tests := []struct {
		name string
		want *ResponseJson
	}{
		{
			name: "test1",
			want: &ResponseJson{
				Code: 400,
				Msg:  "parameters not found",
				Data: nil,
			},
		},
	}
	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			if got := GetParamsEmptyErrorResponseJson(); !reflect.DeepEqual(got, tt.want) {
				t.Errorf("GetParamsEmptyErrorResponseJson() = %v, want %v", got, tt.want)
			}
		})
	}
}

func TestReceiveFile(t *testing.T) {
	type args struct {
		r   *http.Request
		key string
	}
	tests := []struct {
		name    string
		args    args
		want    string
		wantErr bool
	}{
		// TODO: Add test cases.
		{
			name: "test1",
			args: args{
				r:   nil,
				key: "",
			},
			want:    "",
			wantErr: true,
		},
	}
	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			got, err := ReceiveFile(tt.args.r, tt.args.key)
			if (err != nil) != tt.wantErr {
				t.Errorf("ReceiveFile() error = %v, wantErr %v", err, tt.wantErr)
				return
			}
			if got != tt.want {
				t.Errorf("ReceiveFile() = %v, want %v", got, tt.want)
			}
		})
	}
}
